﻿using EasyDDD.AdminModule.Domain.AggregateSysMenu;

namespace EasyDDD.AdminModule.Application.CommandsSysMenu
{
    public record SysMenuDeleteCommand : ICommand
    {
        public Guid Id { get; set; }
    }

    public class SysMenuDeleteCommandHandler(
     Repository.SysMenuRepository repository,
     //IMapper mapper,
     ILogger<SysMenuDeleteCommandHandler> logger)
     : ICommandHandler<SysMenuDeleteCommand>
    {
        public async Task Handle(SysMenuDeleteCommand request, CancellationToken cancellationToken)
        {
            logger.LogDebug("命令 SysMenuDeleteCommandHandler");
            //return service.Delete(new SysMenuId(request.Id));
            //TODO: 这个验证逻辑是不是该放领域服务里
            var entity = await repository.GetAsync(new SysMenuId(request.Id));
            entity.Delete();
        }
    }
}
